/*
 *  Yatun  - Yet another tunneling application
 *
 *  Michal Demin - 2007
 *
 *  ConfigParser.h
 *  Configuration file parser header file
 *
 */

#ifndef CONFIG_PARSER_h
#define CONFIG_PARSER_h

#define LINE_SIZE	80

#define T_INT		'i'
#define T_FLOAT		'f'
#define T_STRING	's'
#define T_BOOL		'b'


struct t_Property {
    char *Name;
    char *Value;
    t_Property *Next;
};

class ConfigParser {
    private:
	// variable 
	FILE *fd;
	char *filename;
	char *secName; // meno nacitanej sekcie ... 
	t_Property *Properties;
	
	// metody
	char *getNextLine();
	char *trimWhitespace(char*);
	int findChar(char *, uint, char);
	void destroyProperties();
	
    public:
	ConfigParser();
	~ConfigParser();
	
	int Open(const char *);
	int GetSection(const char *);
	t_Property *GetProperty(const char *);
	int GetPropertyByType(const char *, void *, char);
	
	void Close();
};


#endif
